using AiQiuQuan.Sport.Model.Models;
using AiQiuQuan.Sport.Core;
using AiQiuQuan.Sport.WebApi.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace AiQiuQuan.Sport.WebApi.Controllers
{
    /// <summary>
    /// 平台用户管理
    /// </summary>
    public class PlatformFramworkUserController : PcApiController
    {
        private readonly IFrameworkUsersService _frameworkUsersService;

        /// <summary>
        /// cotr
        /// </summary>
        public PlatformFramworkUserController(
            IFrameworkUsersService frameworkUsersService)
        {
            _frameworkUsersService = frameworkUsersService;
        }

        /// <summary>
        /// 登录
        /// </summary>
        [HttpPost("login")]
        [AllowAnonymous]
        public async Task<UnaryResult<FrameworkUsersLoginResultDto>> LoginAsync(FrameworkUsersLoginDto request)
        {
            var result = await _frameworkUsersService.LoginAsync(request);
            return result;
        }

        /// <summary>
        /// 注销登录
        /// </summary>
        [HttpPost("logout")]
        public async Task<UnaryResult> LogOutAsync()
        {
            var result = await _frameworkUsersService.LogOutAsync();
            return result;
        }

        /// <summary>
        /// 查询一条记录
        /// </summary>
        [HttpGet("get")]
        public async Task<UnaryResult<FrameworkUsersDto>> GetAsync(Guid id)
        {
            var result = await _frameworkUsersService.GetAsync(id);
            return UnaryResult.Succeed(result);
        }

        /// <summary>
        /// 查询用户及角色
        /// </summary>
        [HttpPost("query")]
        public async Task<UnaryResult<FrameworkUsersLoginResultDto>> QueryAsync()
        {
            var result = await _frameworkUsersService.QueryAsync();
            return UnaryResult.Succeed(result);
        }

        /// <summary>
        /// 我管理的场馆分页列表
        /// </summary>
        [HttpPost("pagelist_venue_self")]
        public async Task<UnaryResult<PageResult<VenueInfoDto>>> GetMyVenuePageListAsync(PageRequest request)
        {
            var result = await _frameworkUsersService.GetMyVenuePageListAsync(request);
            return UnaryResult.Succeed(result);
        }
    }
}
